package com.ymatou.iapi.exp.testcase;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.reflect.TypeToken;
import com.ymatou.iapi.exp.parameter.GetOverstepUserCountBean;
import com.ymatou.iapi.exp.service.GetOverstepUserCountCall;
import com.ymatou.iapi.exp.service.GetPrivilegeConfigListCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.PrivilegeConfig;
import com.ymttest.database.sqlwapper.ExpWapper;
/**
*获取当前用户的经验值超出了多少个用户
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetPrivilegeConfigList{
	private static GetPrivilegeConfigListCall GetPrivilegeConfigListCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取等级与特权的映射关系");
	}

	@Before
	public void caseUp() {
		GetPrivilegeConfigListCall=new GetPrivilegeConfigListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(GetPrivilegeConfigListCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetPrivilegeConfigList_001() {
		Logger.start(true,"获取等级与特权的映射关系成功");
		try {
			GetPrivilegeConfigListCall.callService();
			Logger.verifyEquals("success", GetPrivilegeConfigListCall.getErrorMessage(), "验证errormessage");
			Logger.verifyEquals("true", GetPrivilegeConfigListCall.getSuccess(), "验证success");
			Logger.verifyEquals("0", GetPrivilegeConfigListCall.getErrorCode(), "验证ErrorCode");
			List<PrivilegeConfig> re = GetPrivilegeConfigListCall.getResult();
			Map<Integer,PrivilegeConfig> m=new HashMap<Integer,PrivilegeConfig>();
			for (PrivilegeConfig privilegeConfig : re) {
				m.put(privilegeConfig.getId(),privilegeConfig);
			}
			List<PrivilegeConfig> list = new ExpWapper().selectprivilegeconfig();
			for (PrivilegeConfig privilegeConfig : list) {
				int id=privilegeConfig.getId();
				Logger.verifyEquals(m.get(id).getBeneficiary(), privilegeConfig.getBeneficiary(), "验证Beneficiary");
				Logger.verifyEquals(m.get(id).getDescription(), privilegeConfig.getDescription(), "验证Description");
				Logger.verifyEquals(m.get(id).getPrivilege(), privilegeConfig.getPrivilege(), "验证Privilege");
				Logger.verifyEquals(m.get(id).getV1(), privilegeConfig.getV1(), "验证V1");
				Logger.verifyEquals(m.get(id).getV2(), privilegeConfig.getV2(), "验证V2");
				Logger.verifyEquals(m.get(id).getV3(), privilegeConfig.getV3(), "验证V3");
				Logger.verifyEquals(m.get(id).getV4(), privilegeConfig.getV4(), "验证V4");
				Logger.verifyEquals(m.get(id).getV5(), privilegeConfig.getV5(), "验证V5");
				Logger.verifyEquals(m.get(id).getV6(), privilegeConfig.getV6(), "验证V6");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}